package com.tuozixuan.javafx.shape;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.CubicCurve;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

public class CubicCurveDemo2 extends Application {

	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage stage) {
	       Group root = new Group();

	        // bending curve
	        Rectangle srcRect1 = new Rectangle(100,100,50,50);
	        Rectangle dstRect1 = new Rectangle(300,300,50,50);

	        CubicCurve curve1 = new CubicCurve( 125, 150, 125, 200, 325, 200, 325, 300);
	        curve1.setStroke(Color.BLACK);
	        curve1.setStrokeWidth(1);
	        curve1.setFill(null);

	        root.getChildren().addAll( srcRect1, dstRect1, curve1);

	        // steep curve
	        Rectangle srcRect2 = new Rectangle(100,400,50,50);
	        Rectangle dstRect2 = new Rectangle(200,500,50,50);

	        CubicCurve curve2 = new CubicCurve( 125, 450, 125, 450, 225, 500, 225, 500);
	        curve2.setStroke(Color.BLACK);
	        curve2.setStrokeWidth(1);
	        curve2.setFill( null);

	        root.getChildren().addAll( srcRect2, dstRect2, curve2);

	        stage.setScene(new Scene(root, 800, 600));
	        stage.show();
	}
}
